package org.coldlife.sim.grav;

import javax.vecmath.Vector3d;

public class Particle {

	private Vector3d position;
	private Vector3d velocity;
	
	public Particle() {
		position = new Vector3d();
		velocity = new Vector3d();
	}
	
	
	public Vector3d getDisplacement(Particle other) {
		Vector3d p1 = getPosition();
		Vector3d p2 = other.getPosition();
		
		Vector3d displacement = new Vector3d(p1);
		displacement.sub(p2);
		return displacement;
	}
	
	
	public double getDistance(Particle other)
	{
		Vector3d displacement = getDisplacement(other);
		double distance = displacement.length();
		return Math.abs(distance);
	}


	
	/**
	 * updates the particles position based on its current velocity and the given delta t.
	 */
	public void updatePosition(double t)
	{
		Vector3d displacement = new Vector3d(velocity);
		displacement.scale(t);
		
		position.add(displacement);
	}
	
	public Vector3d getPosition() {
		return position;
	}
	public void setPosition(Vector3d position) {
		this.position = position;
	}
	public Vector3d getVelocity() {
		return velocity;
	}
	public void setVelocity(Vector3d velocity) {
		this.velocity = velocity;
	}
}
